package com.steven.ourcontest.team.api

import com.steven.ourcontest.main.bean.TeamTop5DetailRes
import com.steven.ourcontest.net.BaseResponse
import com.steven.ourcontest.net.EmptyResponse
import com.steven.ourcontest.team.bean.MatchInfoRes
import com.steven.ourcontest.team.bean.TeamApplyRes
import com.steven.ourcontest.team.bean.TeamDetail
import com.steven.ourcontest.team.bean.TeamInfoRes
import io.reactivex.Observable
import retrofit2.http.*

interface TeamApiService {

    @FormUrlEncoded
    @POST("/team/queryUserTeam")
    fun queryUserTeam(
        @Field("user") user: Long
    ): Observable<BaseResponse<TeamInfoRes>>

    @FormUrlEncoded
    @POST("/team/updateStatus")
    fun updateTeamStatus(
        @Field("teamId") teamId: Long,
        @Field("status") status: Boolean
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/team/apply")
    fun applyToTeam(
        @Field("teamId") teamId: Long
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/team/updateName")
    fun updateTeamName(
        @Field("teamId") teamId: Long,
        @Field("teamName") teamName: String
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/team/updateApply")
    fun updateApplyToTeam(
        @Field("applyId") applyId: Long,
        @Field("pass") pass: Boolean
    ): Observable<BaseResponse<EmptyResponse>>

    @POST("/team/queryApply")
    fun queryApplyToMe(): Observable<BaseResponse<TeamApplyRes>>

    @FormUrlEncoded
    @POST("/team/queryDetail")
    fun queryTeamDetail(@Field("teamId") teamId: Long): Observable<BaseResponse<TeamDetail>>

    @FormUrlEncoded
    @POST("/match/search")
    fun searchMatchList(
        @Field("matchName") matchName: String,
        @Field("lastId") lastId: Long
    ): Observable<BaseResponse<MatchInfoRes>>

    @FormUrlEncoded
    @POST("/team/add")
    fun createTeam(
        @Field("teamName") teamName: String,
        @Field("matchId") matchId: Long,
        @Field("matchName") matchName: String,
        @Field("url") url: String
    ): Observable<BaseResponse<EmptyResponse>>

    @FormUrlEncoded
    @POST("/team/addPageViews")
    fun addTeamPageViews(
        @Field("teamId") teamId: Long
    ): Observable<BaseResponse<EmptyResponse>>

    @POST("/team/searchTop5")
    fun searchTop5Team(): Observable<BaseResponse<TeamTop5DetailRes>>

    @POST("/team/querySameSchool")
    fun searchSameSchoolTeam(): Observable<BaseResponse<TeamInfoRes>>

    @FormUrlEncoded
    @POST("/team/queryNew")
    fun searchNewCreateTeam(@Field("lastCreateTime") lastCreateTime: Long): Observable<BaseResponse<TeamInfoRes>>
}